package com.example.demo.controller;

import com.example.demo.service.MapService;

import org.json.JSONException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RequestMapping("/api")
@RestController
public class MapController {
    @Resource
    private MapService mapService;

    @GetMapping(value="/map",produces = "application/json")
    public ResponseEntity <List<?>> mapInitialization() throws JSONException {
        List<Map<String,Object>> pois_list = mapService.getPoi();
        List<Map<String,Object>> cars_list = mapService.getCar();
        List<List<Map<String, Object>>> list= new ArrayList<>();
        list.add(pois_list);
        list.add(cars_list);
        return ResponseEntity.ok(list);
    }
}
